<template>
  <!-- 教学反思 -->
  <div class="teachingReflection">
    <div v-if="listData" class="marginT30">
      <editor
        v-model="listData.resList[programmeIndex].resList[classHourIndex].resTeachingReflection.content"
      />
    </div>
    <div class="button-box">
      <!-- <button class="default">保存</button> -->
      <button class="submit" @click="save">保 存</button>
    </div>
  </div>
</template>

<script>
import editor from '@/components/Tinymce/index';
import { saveResTeachingReflection } from '@/api/content';
export default {
  name: 'TeachingReflection',
  components: {
    editor
  },
  props: ['list', 'programmeInx', 'classHourInx'],
  data () {
    return {
      classHourIndex: this.classHourInx,
      programmeIndex: this.programmeInx,
      listData: this.list
    };
  },
  computed: {
  },
  watch: {
  },
  created () {
  },
  methods: {
    // newContent (val) {
    //   console.log('val:', val);
    //   //  this.ruleForm.atvDescribe = val;
    // },
    save () {
      console.log(this.listData.resList[this.programmeIndex].resList[this.classHourIndex].resTeachingReflection.content);
      // this.listData = updateTags(this.listData, this.options);
      var data = {
        content: this.listData.resList[this.programmeIndex].resList[this.classHourIndex].resTeachingReflection.content || '',
        id: this.listData.resList[this.programmeIndex].resList[this.classHourIndex].resTeachingReflection.id || '', // 教学反思id
        teachingDesignId: this.listData.baseInfo.id || '', //  备课id
        teachingDesignResId: this.listData.resList[this.programmeIndex].resList[this.classHourIndex].id || '' // 课时id
      };
      // console.log(JSON.stringify(tagsData));

      saveResTeachingReflection(data).then(res => {
        console.log(res.data);
        this.$message({
          message: '保存成功!',
          type: 'success'
        });
      });
    }
  }
};
</script>

<style lang='scss' scoped>
.button-box {
  margin-top: 24px;

  .default {
    width: 94px;
    height: 40px;
    background: rgba(255, 255, 255, 1);
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    margin-right: 30px;
    cursor: pointer;
  }
  .submit {
    width: 128px;
    height: 40px;
    border: none;
    background: rgba(84, 184, 123, 1);
    border-radius: 4px;

    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: rgba(255, 255, 255, 1);
    line-height: 24px;
    cursor: pointer;
  }
}
</style>
